package com.example.shop.modules.sys.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.shop.persistence.entity.Goods;
import com.example.shop.persistence.entity.GoodsDetail;
import com.example.shop.persistence.mapper.GoodsDetailMapper;
import com.example.shop.persistence.mapper.GoodsMapper;
import com.example.shop.modules.sys.service.IGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.shop.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author jason
 * @since 2019-12-16
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    @Autowired
    private GoodsDetailMapper goodsDetailMapper;

    /*
    根据ID查询商品详细信息
    */
    @Override
    public Map selectGoodsInfoAll(Integer id){

        QueryWrapper<Goods> ew = new QueryWrapper<>();

        ew.eq("a.id", id);

        return goodsMapper.selectGoodsInfoAll(ew);
    }


    /*
    查询商品列表
     */
    @Override
    public IPage<Goods> selectGoodsList(Page<Goods> page, QueryWrapper<Goods> ew){
        return page.setRecords(goodsMapper.selectGoodsAllList(page,ew));
    }


}
